package com.itjiange.utils;

import java.util.Random;

/**
 * 生成随机验证码
 *
 * @author ItJiange
 * @date 2023/10/19
 */
public class RandomCodeUtils {
    private static final String CHAR_SET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

    public static String randomString() {
        StringBuilder sb = new StringBuilder();
        Random random = new Random();

        for(int i=0; i<6; i++) {
            int index = random.nextInt(CHAR_SET.length());
            char c = CHAR_SET.charAt(index);
            sb.append(c);
        }

        return sb.toString();
    }
}
